package com.hand.wfive.fragment.file

import androidx.lifecycle.MutableLiveData
import com.hand.wfive.entity.FileUpdateEvent
import com.hand.wfive.entity.Params

class FileUnsignFragment : BaseFileFragment() {

    companion object {
        val fileLiveData = MutableLiveData<FileUpdateEvent>()
    }

    override fun init() {
        super.init()
        fileLiveData.observe(this) {
            when (it.type) {
                1 -> mAdapter.remove(it.model)
                2 -> {
                    val position = mAdapter.getItemPosition(it.model)
                    if (position >= 0 && position < mAdapter.itemCount) {
                        mAdapter.setData(position, it.model)
                    }
                }
            }
        }
    }

    override fun emptyMsg() = "暂无待签字文件"

    override fun getType() = Params.fileTypeAll

    override fun getStatus() = Params.fileStatusUnsign

    override fun onUpdateFile(event: FileUpdateEvent) {
        FileAllFragment.fileLiveData.postValue(event)
    }
}